//
//  UIView+extension.swift
//  DWater-Swift
//
//  Created by mac on 2017/4/18.
//  Copyright © 2017年 Dimon.胡亚宾. All rights reserved.
//

import Foundation
import UIKit
public extension UIView {
    
    public var left : CGFloat {
        let viewLeft = self.frame.origin.x;
        return viewLeft
    }
    
    public func setLeft(_ x : CGFloat) {
        var rect      = self.frame;
        rect.origin.x = x;
        self.frame    = rect;
    }
    
    public var top : CGFloat {
        return self.frame.minY
    }
    
    public func setTop(_ top:CGFloat){
        var rect      = self.frame;
        rect.origin.y = top
        self.frame    = rect;
    }
    
    
    public var right : CGFloat {
        return self.frame.maxX;
    }
    
    public func setRight(_ right:CGFloat){
        var rect      = self.frame;
        rect.origin.x = right - rect.size.width
        self.frame    = rect;
    }
    
    public var bottom : CGFloat {
        return self.frame.maxY
    }
    
    public func setBottom(_ bottom:CGFloat){
        var rect      = self.frame;
        rect.origin.x = bottom - rect.size.height
        self.frame    = rect;
    }
    
    public var centerX : CGFloat {
        return self.center.x
    }
    
    public func setCenterX(_ centerX:CGFloat){
        self.center = CGPoint(x: centerX, y: self.center.y)
    }
    
    public var centerY : CGFloat {
        return self.center.y
    }
    
    public func setCenterY(_ centerY:CGFloat){
        self.center = CGPoint(x: self.center.x, y: centerY)
    }
    
    
    
    public var width : CGFloat {
        return self.frame.width;
    }
    
    public func setWidth(_ width : CGFloat) {
        var rect        = self.frame;
        rect.size.width = width;
        self.frame      = rect;
    }
    
    public var height : CGFloat {
        return self.frame.height
    }
    
    public func setHeight(_ height : CGFloat) {
        var rect         = self.frame;
        rect.size.height = height;
        self.frame       = rect;
    }
  
    
    public var size : CGSize {
        return self.frame.size
    }
    


    


    
    
}
